package cn.yunhe.services;

import cn.yunhe.dao.UserDao;
import cn.yunhe.entity.User;
import cn.yunhe.util.SqlSessionFactoryUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.HashMap;
import java.util.Map;

public class UserLoginService {
    SqlSession session = null;
    UserDao userDaoDao = null;

    public User login(String cname,String cpass){
        User user=null;
        try {
            session= SqlSessionFactoryUtil.getSqlSession();
            userDaoDao=session.getMapper(UserDao.class);
            Map map=new HashMap();
            map.put("cname",cname);
            map.put("cpass",cpass);
            user=userDaoDao.login(map);

        }finally {
            session.close();
        }

        return user;
    }

}
